import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from "path";
// @ts-ignore
import { api } from "/@/utils";

function pathResolve(dir: string) {
  return resolve(process.cwd(), '.', dir);
}
export default defineConfig({
  server: {
    proxy: {
      '/api': {
        target: api,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '/api')
      }
    }
  },
  build: {
    target: ['es2015']
  },
  plugins: [
    vue()
  ],
  resolve: {
    alias: [
      {
        find: /^\/@\//,
        replacement: pathResolve('src') + '/',
      }
    ]
  },
  css:{
    preprocessorOptions: {
      scss: {
        sassOptions: {
          additionalData: `@import "./src/assets/main.scss";`,
        }
      }
    }
  }


})
